package com.qf.ssm.controller;

import com.qf.ssm.common.vo.ResponseResult;
import com.qf.ssm.service.StoreService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author KING
 * @ClassName: com.qf.ssm.controller.StoreController
 * @Description: 商家端WEB
 * @date: 2021/10/14 9:05
 */
@RestController
@RequestMapping("/store")
public class StoreController {
    @Resource
    private StoreService storeService;

    /**
     * 查看店铺是否处于营业状态
     *
     * @param storeId
     * @return
     */
    @GetMapping("/operate/{storeId}")
    public ResponseResult<Boolean> isOperate(@PathVariable("storeId") Long storeId) {
        Boolean isOperate = storeService.isOperate(storeId);
        return ResponseResult.success(isOperate);
    }

    /**
     * 停止营业
     *
     * @param storeId
     * @return
     */

    @PostMapping("/close/{storeId}")
    public ResponseResult<Boolean> closeStore(@PathVariable("storeId") Long storeId) {
        Boolean isClose = storeService.closeStore(storeId);
        return ResponseResult.success(isClose);
    }

    @GetMapping("/operate/time/{storeId}")
    public ResponseResult<String> operateTime(@PathVariable("storeId") Long storeId) {
        String time = storeService.operateTime(storeId);
        return ResponseResult.success(time);
    }


}
